﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using Extjs_ReGSharp.Criteria.Factory;
using Extjs_ReGSharp.Criteria;
using Extjs_ReGSharp.Sorting;

namespace Extjs_ReGSharp.InputParsing
{
	internal class InputParser<T>
	{
		#region Data Memebers

		private NameValueCollection m_InputParameters;

		#endregion

		#region Constructor

		public InputParser(NameValueCollection inputParameters)
		{
			m_InputParameters = inputParameters;
		}

		#endregion

		#region Private Methods

		#endregion

		#region Public Methods

		public Filter<T> ExtractFilter()
		{
			CriteriaExtractor<T> extractor = new CriteriaExtractor<T>(m_InputParameters);

			Filter<T> result = extractor.ExtractFilter();

			return result;
		}

		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
		public Sorter<T> ExtractSorter(List<ISortingBehaviourFactory<T>> sortingBehaviourFactoryList)
		{
			SorterExtractor<T> sorter = new SorterExtractor<T>(m_InputParameters);

			Sorter<T> result = sorter.ExtractSorter(sortingBehaviourFactoryList);

			return result;
		}

		public PageData<T> ExtractPageData()
		{
			PageDataExtractor<T> pageDataExtractor = new PageDataExtractor<T>(m_InputParameters);

			PageData<T> result = pageDataExtractor.ExtractPageData();

			return result;
		}


		#endregion
	}
}
